package com.linxiao.payment.core.utils;

import com.egzosn.pay.ali.api.AliPayConfigStorage;
import com.egzosn.pay.common.bean.SignType;
import com.egzosn.pay.common.util.sign.SignUtils;

import java.nio.charset.StandardCharsets;

/**
 * AliPayConfigStorage 工具类
 * @author zhoudong
 */
public class AliPayConfigStorageUtils {
    /**
     * 获取AliPayConfigStorage
     * @param pid   合作者id
     * @param appId 应用id
     * @param keyPublic 支付宝公钥
     * @param keyPrivate    应用私钥
     * @param notifyUrl 异步回调地址
     * @param returnUrl 同步回调地址
     * @return
     */
    public static AliPayConfigStorage getInstance(String pid, String appId, String keyPublic
            , String keyPrivate, String notifyUrl, String returnUrl) {

        AliPayConfigStorage aliPayConfigStorage = new AliPayConfigStorage();
        aliPayConfigStorage.setPid(pid);
        aliPayConfigStorage.setAppId(appId);
//      aliPayConfigStorage.setAppAuthToken("ISV代商户代用，指定appAuthToken");
        aliPayConfigStorage.setKeyPublic(keyPublic);
        aliPayConfigStorage.setKeyPrivate(keyPrivate);
        aliPayConfigStorage.setNotifyUrl(notifyUrl);
        aliPayConfigStorage.setReturnUrl(returnUrl);
        aliPayConfigStorage.setSignType(SignUtils.RSA2.name());
        aliPayConfigStorage.setSeller(null);
        aliPayConfigStorage.setInputCharset(StandardCharsets.UTF_8.name());

        return aliPayConfigStorage;
    }
}
